<?php
	class SoSanh extends CI_Controller
	{
		function Them()
		{
			$this->load->library('cart');
			
			$maks = $this->input->post('maks');
			$tenks = $this->input->post('tenks');
			
			$data = array(
							'id' => $maks,
							'qty' => 1,
							'price' => 10,
             			  	'name' => $tenks
            			);

			$this->cart->insert($data);
			
			$this->load->view('home/danhsach_sosanh_view');
		}
		
		function Xoa()
		{
			$this->load->library('cart');
			
			$rowid = $this->input->post('rowid');
			
			$data = array(
							'rowid' => $rowid,
							'qty' => 0
            			);

			$this->cart->update($data);
			
			$this->load->view('home/danhsach_sosanh_view');
		}
		
		function SoSanhKhachSan()
		{
			$this->load->library('cart');
			
			$str = "";
			foreach($this->cart->contents() as $row)
			{		
				$maks = $row['id'];
				$str = $str . "$maks" . ',';
			}
			
			if($str == "")
				return;
			else
			{
				$this->load->model('khachsan_model');
				$data['DSKhachSan'] = $this->khachsan_model->LayKhachSan_SoSanh($str);
				
				$data['country'] = $this->khachsan_model->layQuocGia();
				$data['select_date'] = date("Y-m-d");
				
				$data['city'] = NULL;
				$data['region'] = NULL;
				
				$data['select_hotel'] = "Nhập tên thành phố hoặc tên khách sạn...";				
				$data['select_country'] = NULL;
				$data['select_city'] = NULL;
				$data['select_region'] = NULL;

				$this->load->view('home/SearchKS_view', $data);				
			}
		}
	}
?>